package org.maylove.wuziqi.dao;

import jakarta.transaction.Transactional;
import org.maylove.wuziqi.pojo.question.Question;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuestionDao extends JpaRepository<Question, Long> {

    Question findByQuestionId(Long questionId);

    @Transactional
    @Modifying
    void deleteByQuestionId(Long questionId);

    @Query(nativeQuery = true, value = "SELECT * FROM question ORDER BY question_id LIMIT ?,?")
    List<Question> getQuestion(Integer pagePos, Integer pageSize);
}
